package com.ruoyi.courseManagement.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.courseManagement.domain.Chapter;
import com.ruoyi.courseManagement.domain.vo.ChapterVO;
import com.ruoyi.courseManagement.mapper.ChapterMapper;
import com.ruoyi.courseManagement.service.ChapterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 课程章节Service业务层处理
 * 
 * @author liao
 * @date 2025-06-10
 */
@Service
public class ChapterServiceImpl implements ChapterService
{
    @Autowired
    private ChapterMapper chapterMapper;

    /**
     * 查询课程章节
     * 
     * @param chapterId 课程章节主键
     * @return 课程章节
     */
    @Override
    public Chapter selectChapterByChapterId(Integer chapterId)
    {
        return chapterMapper.selectChapterByChapterId(chapterId);
    }

    /**
     * 查询课程章节列表
     * 
     * @param chapterVO 课程章节
     * @return 课程章节
     */
    @Override
    public List<ChapterVO> selectChapterList(ChapterVO chapterVO)
    {
        return chapterMapper.selectChapterList(chapterVO);
    }

    /**
     * 新增课程章节
     * 
     * @param chapter 课程章节
     * @return 结果
     */
    @Override
    public int insertChapter(Chapter chapter)
    {
        chapter.setCreateTime(DateUtils.getNowDate());
        return chapterMapper.insertChapter(chapter);
    }

    /**
     * 修改课程章节
     * 
     * @param chapter 课程章节
     * @return 结果
     */
    @Override
    public int updateChapter(Chapter chapter)
    {
        chapter.setUpdateTime(DateUtils.getNowDate());
        return chapterMapper.updateChapter(chapter);
    }

    /**
     * 批量删除课程章节
     * 
     * @param chapterIds 需要删除的课程章节主键
     * @return 结果
     */
    @Override
    public int deleteChapterByChapterIds(Integer[] chapterIds)
    {
        return chapterMapper.deleteChapterByChapterIds(chapterIds);
    }

    /**
     * 删除课程章节信息
     * 
     * @param chapterId 课程章节主键
     * @return 结果
     */
    @Override
    public int deleteChapterByChapterId(Integer chapterId)
    {
        return chapterMapper.deleteChapterByChapterId(chapterId);
    }
}
